<template>
  <div>
    <h1>-----------------</h1>
    <ul>
      <li
        v-for="(item,index) in questionArr"
        :key="index"
        @click="questionClick(item.id,'这是问题'+index+'的答案')"
      >{{item.id}}**********{{item.text}}</li>
    </ul>
  </div>
</template>
<script>
export default {
  data() {
    return {
      questionArr: [], //问题数组
      answerArr: [] //答案数组
    };
  },

  methods: {
    questionClick(uid, val) {
      console.log("接收到的数据", uid, val);
      this.answerArr.push({
        question_id: uid,
        question_answer: val
      });
      console.log("当前已选择的答案", this.answerArr);
    }
  },

  computed: {},

  created() {
    let num = Math.floor(Math.random() * 10);
    for (let i = 0; i < num; i++) {
      let question = {
        id: i,
        text: "问题索引" + i
      };
      this.questionArr.push(question);
    }
    console.log("生成的数据", this.questionArr);
  },

  mounted() {}
};
</script>
<style scoped>
</style>
